package com.zhm.demo.task;

import com.zhm.demo.cloud.IotDebugConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.concurrent.ThreadPoolExecutor;

@Slf4j
//@Component
public class TaskTest {

    @Autowired
    private IotDebugConfig iotDebugConfig;

    @Autowired
    @Qualifier("canRejectPool")
    private ThreadPoolExecutor canRejectPoolExecutor;

    @PostConstruct
    public void init() {

        new Thread(() -> {
            while (true) {
                try {
                    Thread.sleep(10000);
//                    ThreadPoolExecutor packPoolExecutor = (ThreadPoolExecutor) DtpRegistry.getExecutor("packPool");
                    new Thread(() -> {
                        log.info("123 {}", canRejectPoolExecutor.getCorePoolSize());
                        log.info("123 {}", canRejectPoolExecutor.getQueue());
                        log.info("123 {}", canRejectPoolExecutor.getMaximumPoolSize());
                        try {
                            Thread.sleep(60000);
                        } catch (InterruptedException e) {
                            throw new RuntimeException(e);
                        }
                    }).start();
                } catch (Exception e) {
                    log.error("", e);
                }
            }
        }).start();

    }

}
